/**
 * @UiBase.hpp
 * Copyright 2013 (C) FatalEror / Dean Bahari
 * 
 * UiPack is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * See LICENSE file in main folder for more information.
 */

#ifndef _UI_BASE_HPP_
#define _UI_BASE_HPP_

class UiControl;
class UiSizer;

class UiBase {
	HWND                 mHandle;
	UiBase              *mParent;
	std::vector<UiBase*> mChild;
	UiSizer             *mSizer;
	const wchar_t       *mName;
protected:
	unsigned int mID;
	int          mPosX;
	int          mPosY;
	int          mWidth;
	int          mHeight;
	unsigned int mBkColor;
public:
	UiBase(const wchar_t *name = L"", UiBase *parent = NULL);
	~UiBase();

	void close();

	void setHandle(HWND newHandle);
	void setPosition(int x, int y);
	void setPosition(POINT pt);
	void setSize(unsigned int width, unsigned int height);
	void setParent(UiBase *parent);
	virtual void setSizer(UiSizer *sizer);

	void addChild(UiBase *child);
	void addControl(UiControl *control, int width, int height, int x, int y);

	unsigned int    getID();
	POINT           getPosition();
	int             getWidth();
	int             getHeight();
	unsigned int    getBkColor();
	HWND            getHandle();
	UiBase         *getParent();
	const wchar_t  *getName();
	UiSizer        *getSizer();
	unsigned int    getChildCount();

	friend class UiApp;
private:
	virtual LRESULT CALLBACK handleCustomProc(UINT msg, WPARAM wParam, LPARAM lParam);

	static unsigned int currentID;
	static std::vector<UiBase*> baseItem;

	static LRESULT CALLBACK handleWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
};

#endif//_UI_BASE_HPP_